<!-- 无处方表单 -->
<template>
	<view class="no-prescription-form-wrapper">
		<form @submit="formSubmit">
			<view class="uni-common-mt">
				<view class="uni-form-item uni-column">
					<view class="title">描述症状</view>
					<view class="uni-textarea" style="height: 100px;">
						<textarea auto-height name="text" v-model="formData.text" placeholder="描述病情现状,医生根据你的病情合理开具处方" />
					</view>
				</view>
				<view class="uni-form-item uni-column">
					<view class="title">需要的药品</view>
					<view class="uni-textarea" style="height: 100px;">
						<textarea auto-height name="text2" v-model="formData.text2"
							placeholder="描述病情现状,医生根据你的病情合理开具处方" />
					</view>
				</view>
				<view class="uni-form-item uni-column">
					<view class="title">需要开多久的药</view>
					<view class="uni-textarea">
						<uni-data-checkbox mode="button" multiple v-model="formData.timleng" :localdata="hobby">
						</uni-data-checkbox>
					</view>
				</view>
				<!-- <view class="uni-form-item uni-column">
					<view class="">
						<uni-file-picker limit="9" title="最多选择9张图片"></uni-file-picker>
					</view>
				</view> -->
				<div style="margin-bottom: 10px;"></div>
				<button type="primary" class="up-button" form-type="submit">下一步</button>
			</view>
		</form>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations,
		mapActions
	} from 'vuex'
	import graceChecker from "../../common/graceChecker.js"
	import WXBizDataCrypt from "../../common/WXBizDataCrypt.js"
	export default {
		data() {
			return {
				formData: {
					text: '',
					text2: '',
					timleng: '',
					upload_picture_list: '',
					typedate: 0
				},
				checkbox2: [],
				hobby: [{
					text: '7天',
					value: 7
				}, {
					text: '14天',
					value: 14
				}, {
					text: '1个月',
					value: 30
				}, {
					text: '2个月',
					value: 60
				}, {
					text: '3个月',
					value: 90
				}],
			}
		},
		onLoad() {

		},
		methods: {
			
			formSubmit(e) {
				// this.formData.timleng = this.formData.timleng[0] + '天'
				// console.log(this.formData)
				// this.api_user_addcforder()
				this.formData.timleng = this.formData.timleng[0] + '天'
				var rule = [{
						name: "text",
						checkType: "string",
						checkRule: "1,1000",
						errorMsg: "请填写描述症状"
					},
					{
						name: "text2",
						checkType: "string",
						checkRule: "1,1000",
						errorMsg: "请填写需要的药品"
					}
				];
				var formData = e.detail.value;
				var checkRes = graceChecker.check(formData, rule);
				if (checkRes) {
					uni.navigateTo({
						url: '/pages/onlinePrescribe/selectUserCard?formData=' + JSON.stringify(this.formData)
					})
				} else {
					uni.showToast({
						title: graceChecker.error,
						icon: "none"
					});
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	.no-prescription-form-wrapper {
		width: 100%;
		height: 100%;
		padding: 10px;
		background-color: #fff;
		box-sizing: border-box;
	}
</style>